﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Things.ThingsTool
{
    public partial class UpdateOrderStatus : Form
    {
        public UpdateOrderStatus()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            Things.BLL.GoodsOrders goBLL = new BLL.GoodsOrders();
            string strWhere = " Status='" + Things.Common.ConstantString.GoodsOrderSatus.已发货.ToString() + "'";
            List<Things.Model.GoodsOrders> models = goBLL.GetModels(strWhere);
            foreach (Things.Model.GoodsOrders model in models)
            {
                string detail = goBLL.GetKuaiDiXinXi(model.KuaiDiGongSi, model.KuaiDiDanHao, "0", "0");
                if (detail.IndexOf("\"state\":\"3\"") >= 0)
                {
                    model.Status = Things.Common.ConstantString.GoodsOrderSatus.交易成功.ToString();
                    if (goBLL.Update(model) == true)
                    {
                        sb.AppendFormat("订单：{0} 状态更新成功！", model.GoodsOrderNumber.ToString());
                    }
                    else
                    {
                        sb.AppendFormat("订单：{0} 更新失败！", model.GoodsOrderNumber.ToString());
                    }
                }
            }

            txtDetail.Text = sb.ToString();
        }
    }
}
